package com.ruoyi.patrol.controller;

import java.util.List;

import com.ruoyi.patrol.domain.vo.PtFormDetailVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.patrol.domain.PtFormReply;
import com.ruoyi.patrol.service.IPtFormReplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单回复详情Controller
 *
 * @author lkm
 * @date 2022-11-14
 */
@RestController
@RequestMapping("/patrol/reply")
public class PtFormReplyController extends BaseController {
    @Autowired
    private IPtFormReplyService ptFormReplyService;

    /**
     * 查询单回复详情列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:list')")
    @GetMapping("/list")
    public TableDataInfo list(PtFormReply ptFormReply) {
        startPage();
        List<PtFormReply> list = ptFormReplyService.selectPtFormReplyList(ptFormReply);
        return getDataTable(list);
    }

    /**
     * 导出单回复详情列表
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:export')")
    @Log(title = "单回复详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PtFormReply ptFormReply) {
        List<PtFormReply> list = ptFormReplyService.selectPtFormReplyList(ptFormReply);
        ExcelUtil<PtFormReply> util = new ExcelUtil<PtFormReply>(PtFormReply.class);
        return util.exportExcel(list, "reply");
    }

    /**
     * 获取单回复详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(ptFormReplyService.selectPtFormReplyById(id));
    }

    /**
     * 新增单回复详情
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:add')")
    @Log(title = "单回复详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PtFormDetailVo ptFormDetailVo) {
        return toAjax(ptFormReplyService.insertPtFormReply(ptFormDetailVo));
    }

    /**
     * 修改单回复详情
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:edit')")
    @Log(title = "单回复详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PtFormReply ptFormReply) {
        return toAjax(ptFormReplyService.updatePtFormReply(ptFormReply));
    }

    /**
     * 删除单回复详情
     */
    @PreAuthorize("@ss.hasPermi('patrol:reply:remove')")
    @Log(title = "单回复详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ptFormReplyService.deletePtFormReplyByIds(ids));
    }
}
